package query

import (
	"errors"
	"ssadmin/common/query"
	"time"
)

type DeptQuery struct {
	query.Pagination `search:"-"`
	DeptId           string   `form:"id"  search:"type:exact;column:id;table:sys_dept"`
	ParentId         string   `form:"parentId"  search:"type:exact;column:parent_id;table:sys_dept"`
	DeptName         string   `form:"deptName"  search:"type:contains;column:name;table:sys_dept"`
	Type             string   `form:"type"  search:"type:exact;column:type;table:sys_dept"`
	OnlyDept         bool     `form:"onlyDept"  search:"-"`
	CreatorId        string   `form:"-"  search:"-"`
	UserId           string   `form:"-"  search:"-"`
	UserName         string   `form:"-"  search:"-"`
	Lazy             bool     `form:"-"  search:"-"`
	Search           string   `form:"search"  search:"type:contains;column:name;table:sys_dept"`
	DeptIdList       []string `form:"deptIdList"  search:"type:in;column:id;table:sys_dept"`
	NinDeptIdList    []string `form:"notDeptIdList"  search:"type:nin;column:id;table:sys_dept"`
	DeptOrder
}

type DeptOrder struct {
	DeptId     string    `form:"deptIdOrder"  search:"type:order;column:id;table:sys_dept"`
	ParentId   string    `form:"parentIdOrder"  search:"type:order;column:parent_id;table:sys_dept"`
	DeptName   string    `form:"deptNameOrder"  search:"type:order;column:dept_name;table:sys_dept"`
	OrderNum   string    `form:"orderNumOrder"  search:"type:order;column:order_num;table:sys_dept"`
	CreateTime time.Time `form:"createTimeOrder"  search:"type:order;column:create_time;table:sys_dept"`
	ModifyTime time.Time `form:"modifyTimeOrder"  search:"type:order;column:modify_time;table:sys_dept"`
}

func (m *DeptQuery) GetNeedSearch() interface{} {
	return *m
}
func (m *DeptQuery) GetId() (id interface{}, err error) {
	if len(m.DeptId) == 0 {
		return nil, errors.New("ID不能为空")
	}
	return *m, nil
}
